package DataStreamApi.Source读取;


import org.apache.flink.api.common.eventtime.WatermarkStrategy;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.connector.file.src.FileSource;
import org.apache.flink.connector.file.src.reader.TextLineInputFormat;
import org.apache.flink.core.fs.Path;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 *
 */
public class Flink02_File {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment executionEnvironment = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(new Configuration());


        FileSource<String> build = FileSource.forRecordStreamFormat(new TextLineInputFormat(), new Path("data/word.txt")).build();

        /**
         * 在 Apache Flink 中，WatermarkStrategy 是用于处理事件时间（Event Time）的核心组件之一。它主要用于定义如何为流中的数据分配时间戳以及生成水印（Watermark），从而支持基于事件时间的窗口操作和时间敏感的计算。
         */

        DataStreamSource<String> stringDataStreamSource = executionEnvironment.fromSource(build, WatermarkStrategy.noWatermarks(), "Flink02_File");

        stringDataStreamSource.print();
        executionEnvironment.execute();


    }
}
